<script type="text/javascript" src="/shop/api/payment/zhifuqr/js/jquery.qrcode.js"></script>
<script type="text/javascript" src="/shop/api/payment/zhifuqr//js/utf.js"></script>

<div class="ncc-main">
    <div class="ncc-title">
        <h3>订单支付</h3>
        <h5>请扫描下方二维码进行支付，祝您购物愉快</h5>
    </div>
    <div class="ncc-receipt-info mb30">
        <div id="showqrcode">二维码生成中</div>
        <div class="ncc-finish-b">可通过用户中心<a href="<?php echo SHOP_SITE_URL?>/index.php?act=member_order">已买到的商品</a>查看订单状态。</div>
        <div class="ncc-finish-c mb30"><a href="<?php echo SHOP_SITE_URL?>" class="ncc-btn-mini ncc-btn-green mr15"><i class="icon-shopping-cart"></i>继续购物</a><a href="<?php echo SHOP_SITE_URL?>/index.php?act=member_order" class="ncc-btn-mini ncc-btn-acidblue"><i class="icon-file-text-alt"></i>查看订单</a></div>
    </div>
</div>

<script>
        function sQrcode(qdata) {
            $("#showqrcode").empty().qrcode({		// 调用qQcode生成二维码
                render: "canvas",    			// 设置渲染方式，有table和canvas，使用canvas方式渲染性能相对来说比较好
                text: qdata,    				// 扫描了二维码后的内容显示,在这里也可以直接填一个网址或支付链接
                width: "200",              	// 二维码的宽度
                height: "200",             	// 二维码的高度
                background: "#ffffff",     	// 二维码的后景色
                foreground: "#000000",     	// 二维码的前景色
                src: ""    						// 二维码中间的图片
            });
        }

        $.ajax({
            type: "post",
            url: "/shop/index.php?act=zhifuqr&op=zhifuqrOrder",
            data:{
                trade_no:'<?php echo $_GET['trade_no'];?>',
                order_type:'<?php echo $_GET['order_type'];?>',
                hash:'<?php echo $_GET['hash'];?>'
            },
            dataType: "text",
            success: function (data) {
                var result_code = $(data).find("result_code").text();
                if (result_code == "0") {
                    var qrcode = $(data).find("qrcode").text();
                    sQrcode(qrcode);
                } else if (result_code == "1"){
                    $("#showqrcode").html("<h1 style='font-size: 20px'>订单号已经存在，重新下单！</h1>");
                }else {
                    $("#showqrcode").html("<h1 style='font-size: 20px'>出现异常！</h1>");
                }
            },
            error: function () {
                alert("连接失败");
            }
        });

        var didit = false;
        var timer = setInterval(function () {
            $.post('?act=seccode&op=get_order_status', {order_sn: '<?php echo $output[order_sn]?>'}, function (msg) {
                if (msg === 'success' || msg === 'SUCCESS' ) {
                    if (!didit) {
                        layer.msg('支付成功！', {icon: 1}, function () {
                            location.href = '/shop/index.php?act=member_order&op=index';
                        });
                        didit = true;
                        clearInterval(timer);
                    }
                }
            });
        }, 3000);

</script>